package com.stx.blog.action;

import java.util.ArrayList;
import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.stx.blog.service.CategoryService;
import com.stx.blog.service.impl.CategoryServiceImpl;
import com.stx.blog.vo.CategoryVo;

public class CategoryAction extends ActionSupport{
	private CategoryService service;
	private List<CategoryVo> stuList = new ArrayList<CategoryVo>();

	private CategoryVo criteria = null;

	private CategoryVo category = null;

	private Integer id = null;

	public CategoryService getService() {
		return service;
	}

	
	public String list() {

		stuList = service.list(new CategoryVo());

		return "list";
	}

	public String del() {
		service.delCategory(id);

		return "list";
	}

	public String add() {
		service.addCategory(category);

		return "list";
	}

	public String findCategoryById() {
		category = service.findCategoryForUpdate(id);

		return "update";
	}

	public String update() {
		service.updateCategory(category);

		return "list";
	}
	
	public void setService(CategoryService service) {
		this.service = service;
	}

	public List<CategoryVo> getStuList() {
		return stuList;
	}

	public void setStuList(List<CategoryVo> stuList) {
		this.stuList = stuList;
	}

	public CategoryVo getCriteria() {
		return criteria;
	}

	public void setCriteria(CategoryVo criteria) {
		this.criteria = criteria;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public CategoryVo getCategory() {
		return category;
	}

	public void setCategory(CategoryVo category) {
		this.category = category;
	}

}
